Embedding a Script

A script (program) can be executed in the automatic response. By using a script, it is possible to provide a reservation function in cooperation with an external system and update HubSpot data freely.

Enter the keyword "// script" in the first line of the response contents of the automatic response. This will interpret the response as a script.



When writing a script, we recommend that you click the "Edit in editor" button to display the editor dialog.

You can use the following special variables and functions in your scripts.

  • Variables
    • reply
      You can refer to the response of your LINE friends.
    • event
      You can refer to the details of the response contents of your LINE friends.
  • Functions
    • lh.sendMessage
      You can send a message to your LINE friends.
    • lh.updateContact
      Update the contact properties of your LINE friends.

Below is a sample script. Please refer to it.

// script
const date = event.postback.params.date;

// Send message
lh.sendMessage({
type: "text",
text: `Your birthday is ${date}. Thank you for your answer!`
});

// Update HubSpot contact properties
lh.updateContact("line_birthday", Date.parse(date));

Ask your birthday with a LINE message,



Then, the answer is stored in the date property of the contact.



Next: About Analytics Report