Shopify Customer Care powered by GenAI
Building a Shopify Customer Care Agent powered by GenAI with Amazon Bedrock
How does the application work?
๐ค What are Amazon Bedrock Agents?
โ๏ธ Build an Amazon Bedrock Agent in 4 steps
๐ Step 1: Generate Shopify Credentials
Install the app and get credentials:ย ย ๐ Step 2: Create OpenAPI 3.0 spec
๐งโ๐ป Step 3: Create a Lambda Function
๐ Step 4: Creating a Bedrock Agent
๐ฑ The Bedrock Agent is not working: Lambda Function missing permissions
- Create an Amazon Bedrock Agent using one of the foundational models available: Claude Instant V1.
- Create an openAPI 3.0 spec that works with an Amazon Bedrock Agent.
- Create a Lambda Function that meets the requirements to reply an Amazon Bedrock Agent request.
- Create Shopify credentials. Given that we're going to use Shopify for this tutiral we need an Access Token to query its API.
- Write an OpenAPI 3.0 spec that contains all the documentation about our API to instruct the Agento n how to use it.
- Create a Lambda function that will be in charge of querying the order status in Shopify.
- Create and setup the Agent.
- Create a Custom App in Shopify:
- Define permissions:ย
- We only need read_orders permission: https://help.shopify.com/en/manual/apps/app-types/custom-apps#get-the-api-credentials-for-a-custom-appย
- API Endpoints
- HTTP Request Methods accepted
- Parameters for each endpoint and its formatting
- Expected responses.
- /orders/{orderId}: It will receive GET requests and returns the order information. orderId is a required parameter passed in the URL.
- Build a response that meets Bedrock Agent requirements.
- Status Code: 200
- An object with a property named content: application/json
- Enum of object properties.
- Object properties:
- Id: Order Number
- Status: Order Status
- MoreInfo: If the order is fulfilled, info about the tracking number, url, etc.
- Go to AWS Console - Lambda: https://console.aws.amazon.com/lambda/home#/functions
- Create Function
- Author from Scratch
- Set a name
- Runtime: NodeJS (you can use Python or any programming language you feel comfortable with)
- Architecture: X86_64
- URL
- Headers
- Shopify requires a special header to authenticate the requests, named X-Shopify-Access-Token
- Content-Type
- ActionGroup
- Path
- HTTP Method
- Status Code
- Body (responseBody)
- Give your agent a name: OrderInfoAgent
- Require User Input: YES
- Check if you would like to use an existing role or create a new one, encription and timeout (how long the session will last), and tags.
- Select the FM (Foundational Model):
- Here's a guide about how to choose a LLM : https://community.aws/posts/how-to-choose-your-llm
- If you don't see any LLM in the dropdown, this is because you need to enable them: (https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html).
- Write the instructions for your agent: It is super important to write an excellent prompt, even though the Foundational Model might be capable of understanding multiple languages, writing the prompot in English will make thigs easier, ie: You're a kind customer care agent that is here to provide order status information to our customers, on each response you'll provide as much information as you can grab about the order and you'll always thank our customer for being a loyal customer, if you don't know the answer tell the customer to contact customercare@mycompany.com
- Name: GetOrderInformation
- Select the Lambda Function created in the previous step
- Select the OpenAPI spec
4) Don't create a knowledgebase, click Next, review all the information and click Create Agent.
- In the Lambda Function go to Configurations -> Permissions
- In the section resource based policy statements click "Add Permissions"
ย 3. Select AWS Service and open the services list. Unfortunately, Amazon Bedrock (at the moment of writing this article) is not part of this list. Select: Other
- Fill in the information
- Understand what customer wants
- Look for the information needed, invoke an API to execute an action.
- Provide the answer to the customer.
ย