# Cheat Sheet: CognigyScript  
CognigyScript can be used in order to add dynamic and executable content to any kind of virtual chat/voice conversation. Since there are a lot of different helpful examples, this cheat sheet provides an overview.

- [CognigyScript Documentation](https://docs.cognigy.com/ai/build/cognigy-script/)

# General

| Script | Description |
| --- | --- |
| ```<br>{{input.slots.SLOT_NAME[0].keyphrase}}<br>``` | Extracts the first found keyphrase for the slot with the name SLOT_NAME |
| ```<br>{{JSON.stringify(input.data)}}<br>``` | Can be used inside of a Say Node in order to display a JSON object as text. Mostly, it is used for debugging purposes. The example shown on the left shows the information the virtual agent received in `input.data`. |

# Date & Time

| Script | Description |
| --- | --- |
| ```<br>{{input.slots.DATE[0].start.plain}}<br>``` | Returns the locale, human-readable, date information if the user sent a date. Example: July 23, 2021 |
| ```<br>{{moment(input.slots.DATE[0].start.ISODate).format("MMM Do YY")}}<br>``` | Format a given date that the user provided in the last message. [Read more here](https://momentjs.com/). |
| ```<br>{{input.currentTime.hour}}<br>``` | Get the hour of the current incoming message in order to greet the user appropriately. |

### Best Practices

- [Cognigy.AI Bot Building Checklist](https://support.cognigy.com/hc/en-us/articles/360018496419-Cognigy-AI-Bot-Building-Checklist)
- [Cognigy’s NLU Execution Order Explained](https://support.cognigy.com/hc/en-us/articles/16558780569884-Cognigy-s-NLU-Execution-Order-Explained)
- [Difference Between Go To and Execute Node](https://support.cognigy.com/hc/en-us/articles/16221971132444-Difference-Between-Go-To-and-Execute-Node)
- [Explaining No-Translation Markers](https://support.cognigy.com/hc/en-us/articles/16221389567900-Explaining-No-Translation-Markers)
- [Best Practices: Testing your Virtual Agents with Playbooks](https://support.cognigy.com/hc/en-us/articles/9585431937948-Best-Practices-Testing-your-Virtual-Agents-with-Playbooks)
- [Voice: Strategies for Hard to Understand Phrases](https://support.cognigy.com/hc/en-us/articles/7456424115612-Voice-Strategies-for-Hard-to-Understand-Phrases)
- [Universal skills for Chat and Voice](https://support.cognigy.com/hc/en-us/articles/7138355918876-Universal-skills-for-Chat-and-Voice)
- [Avoid customer frustration](https://support.cognigy.com/hc/en-us/articles/5949294556572-Avoid-customer-frustration)
- [Get the conversation going](https://support.cognigy.com/hc/en-us/articles/5937352099484-Get-the-conversation-going)
- [Best Practices: Building a Deployment Pipeline for Cognigy AI Agents](https://support.cognigy.com/hc/en-us/articles/4798756787740-Best-Practices-Building-a-Deployment-Pipeline-for-Cognigy-AI-Agents)
