{"action":"closed","issue":{"url":"https://api.github.com/repos/danielberkompas/telephonist/issues/5","labels_url":"https://api.github.com/repos/danielberkompas/telephonist/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/danielberkompas/telephonist/issues/5/comments","events_url":"https://api.github.com/repos/danielberkompas/telephonist/issues/5/events","html_url":"https://github.com/danielberkompas/telephonist/issues/5","id":128061140,"number":5,"title":"Access to current state from within transition?","user":{"login":"brentonannan","id":3326773,"avatar_url":"https://avatars.githubusercontent.com/u/3326773?v=3","gravatar_id":"","url":"https://api.github.com/users/brentonannan","html_url":"https://github.com/brentonannan","followers_url":"https://api.github.com/users/brentonannan/followers","following_url":"https://api.github.com/users/brentonannan/following{/other_user}","gists_url":"https://api.github.com/users/brentonannan/gists{/gist_id}","starred_url":"https://api.github.com/users/brentonannan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brentonannan/subscriptions","organizations_url":"https://api.github.com/users/brentonannan/orgs","repos_url":"https://api.github.com/users/brentonannan/repos","events_url":"https://api.github.com/users/brentonannan/events{/privacy}","received_events_url":"https://api.github.com/users/brentonannan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/danielberkompas/telephonist/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-01-22T01:30:02Z","updated_at":"2016-01-22T17:45:31Z","closed_at":"2016-01-22T17:45:31Z","body":"Hi Daniel,\r\n\r\nI'm having some trouble with keeping state between many calls to `process`. e.g: I have a menu that prompts for an eta, then confirms that eta, and I would like to then keep that eta in state:\r\n\r\n```\r\n  state :prompt, _twilio, _job do\r\n    gather method: \"GET\" do\r\n      say dgettext(\"call_flows.job.update_eta\", \"Enter the ETA time in minutes and then press #, or press # to go back\"), voice: \"alice\", language: Gettext.get_locale(TelephoneProvisioner.Gettext)\r\n    end\r\n    redirect method: \"GET\"\r\n  end   \r\n\r\n  state :confirmation, _twilio, %{eta: %{unconfirmed: minutes}} do\r\n    gather numDigits: 1, method: \"GET\" do\r\n      say dgettext(\"call_flows.job.update_eta\", \"The time you entered is %{eta} minutes\", %{eta: minutes}), voice: \"alice\", language: Gettext.get_locale(TelephoneProvisioner.Gettext)\r\n      say menu_option(\"1\", dgettext(\"call_flows.job.update_eta\", \"if this is correct\")), voice: \"alice\", language: Gettext.get_locale(TelephoneProvisioner.Gettext)\r\n      say menu_option(\"2\", dgettext(\"call_flows.job.update_eta\", \"to update the ETA\")), voice: \"alice\", language: Gettext.get_locale(TelephoneProvisioner.Gettext)\r\n    end   \r\n  end \r\n\r\n  state :confirmed, _twilio, job do\r\n    say dgettext(\"call_flows.job.update_eta\", \"ETA confirmed at %{eta} minutes\", %{eta: minutes}), voice: \"alice\", language: Gettext.get_locale(TelephoneProvisioner.Gettext)\r\n    redirect method: \"GET\"\r\n  end   \r\n\r\n  def transition(:prompt, %{Digits: minutes} = twilio, job) do\r\n    job = Map.put(job, :eta, %{unconfirmed: minutes})\r\n    state :confirmation, twilio, job\r\n  end \r\n\r\n  def transition(:confirmation, %{Digits: \"1\"} = twilio, job) do\r\n    state :confirmed, twilio, job\r\n  end   \r\n\r\n  def transition(:confirmation, %{Digits: \"2\"} = twilio, job) do\r\n    state :prompt, twilio, job\r\n  end   \r\n```\r\n\r\nThe problem is that I don't have access to the `job.eta.unconfirmed` from the `:confirmation` state when I get to the `def transition(:confirmation, %{Digits: \"1\"} = twilio, job)` - `job` is newly injected from the `process` call on my HTTP endpoint.\r\n\r\nIs there a way to use the existing state in transitions?\r\n\r\nAs a side note, you can see that I'm having to repeat `voice: \"alice\", language: Gettext.get_locale(...)` for all of my say calls - is there a way around this?\r\n\r\nCheers,\r\nBrenton."}}