bumpy-butcher-41910
09/27/2023, 6:52 PMcustom payload
trigger instead of the usual Conversation Start
trigger to initiate the chat when the form is submitted.
To bring the trigger payload into your bot, use this code:
jsx
const { name, email, linkedin, message, position } = event.payload.payload
Create a form on your website:
html
<form id='myform'>
<label for="name">Full Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="linkedin">Linkedin URL:</label>
<input type="text" id="linkedin" name="linkedin" required>
<label for="message">Cover Letter/Message:</label>
<textarea id="message" name="message" rows="7"></textarea>
<button type="submit">Submit</button>
</form>
Embed your bot with this code, ensuring that the chat widget is hidden:
html
<script>
window.botpressWebChat.init({
"composerPlaceholder": "Chat with bot",
"botConversationDescription": "This chatbot was built with Botpress",
"botId": "da359935-a341-4c1d-bc05-cbdbd10a5444",
"hostUrl": "https://cdn.botpress.cloud/webchat/v1",
"messagingUrl": "https://messaging.botpress.cloud",
"clientId": "da359935-a341-4c1d-bc05-cbdbd10a5444",
"lazySocket": true,
"hideWidget": true,
"useSessionStorage": true,
"enableConversationDeletion": true,
"showPoweredBy": true
});
</script>
Use the form submission button to start the chat: [SEE ATTACHED .txt FILE FOR CODE]
This code ensures that the bot widget is ready before sending the payload to the bot. Use sendPayload
to match the bot's trigger for payloads.
Now, you should be able to see the payload in the bot logs when everything works correctly.
Happy bot building!mammoth-lamp-91104
09/28/2023, 6:40 AMmammoth-lamp-91104
09/28/2023, 8:11 AMmammoth-lamp-91104
09/28/2023, 8:13 AMfamous-jewelry-85388
09/28/2023, 7:39 PMfamous-jewelry-85388
09/28/2023, 7:40 PMmammoth-lamp-91104
09/29/2023, 8:43 AMmammoth-lamp-91104
09/29/2023, 8:44 AMfamous-jewelry-85388
09/29/2023, 3:51 PMjolly-policeman-82775
01/07/2024, 1:18 PMjolly-policeman-82775
01/07/2024, 1:18 PMjolly-policeman-82775
01/08/2024, 2:31 PMjolly-policeman-82775
01/08/2024, 2:31 PMbest-army-74344
01/12/2024, 3:28 PMjolly-policeman-82775
01/12/2024, 3:45 PMjolly-policeman-82775
02/09/2024, 7:48 AM