Skip to content

AWS Lex v2 bot response card giving error on twilio

0

Problem statement: I want to access Lex V2 chatbot with response card buttons on WhatsApp.

I created a Lex V2 bot, and created a channel for Twilio. Connected Twilio through WhatsApp, and able to use my bot fine for plaintext responses. But in my bot, I also return a response card with buttons for one of the slot values. This works fine on AWS console, but when I run it through Twilio, it doesnt work, doesnt return anything

asked a year ago96 views
1 Answer
0

The issue you're experiencing with response cards not working through Twilio for your Lex V2 bot is likely due to differences in how response cards are handled between the AWS console and external channels like Twilio WhatsApp.

When using Lex V2 with external channels, the response format needs to be adjusted to ensure compatibility. For Twilio and WhatsApp integration, response cards with buttons are not directly supported in the same way they appear in the AWS console.

To address this, you'll need to modify your Lambda function or bot configuration to handle the response differently when it's being sent through Twilio. Instead of using the responseCard format, you should structure your response as a series of text messages or use a format that Twilio can interpret for WhatsApp.

Here are some steps you can take:

  1. Modify your Lambda function to detect when the request is coming from Twilio/WhatsApp.

  2. For Twilio/WhatsApp requests, instead of using a responseCard, convert the button options into a numbered or bulleted list within the text message.

  3. Ensure that your response follows the correct Lex V2 format, which includes a "sessionState" object and a "messages" array.

  4. In the "messages" array, include your text content with the options listed out.

  5. You may need to implement a way to handle user selections based on text input rather than button clicks.

Remember that the exact implementation will depend on how Twilio is set up to handle WhatsApp messages and how you want the interaction to flow. You might need to consult Twilio's documentation for WhatsApp integration to ensure you're formatting the messages in a way that WhatsApp can display properly.

By adapting your response format for the Twilio channel, you should be able to provide a similar interactive experience to users on WhatsApp, even without the direct use of response card buttons.

Sources
Lex V2 Test Bot responseCard not showing | AWS re:Post
Amazon Lex API Call Fails: "Invalid Bot Configuration: Amazon Lex could not access your Amazon Bedrock Agent" | AWS re:Post

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.