initConversation

Initiates a conversation with the Nutrition Advisor.

 /**
   * Initiates a conversation with the Nutrition Advisor.
   * @returns A Promise resolving to the status of the conversation initiation.
   */
  initConversation(): Promise<PassioAdvisorResultStatus | null>

Example

import { NutritionAdvisor } from '@passiolife/nutritionai-react-native-sdk-v3'
export type SDKStatus = 'Success' | 'Error' | 'Init'

  const [loadingState, setLoadingState] = useState<SDKStatus>('Init')

  useEffect(() => {
    async function configure() {
      try {
            NutritionAdvisor.initConversation()
              .then((item) => {
                setLoadingState(
                  item?.status === 'Success' ? 'Success' : 'Error'
                )
              })
              .catch((error) => {
                setLoadingState(error)
              })
      } catch (err) {
        console.error(`PassioSDK Error ${err}`)
        setLoadingState('Error')
      }
    }
    configure()
  }, [])

Last updated